Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Painless: Move More Logic to PainlessLookup #32689

Merged
merged 75 commits into from
Aug 8, 2018
Merged

Conversation

jdconrad
Copy link
Contributor

@jdconrad jdconrad commented Aug 7, 2018

This moves some run-time lookups for methods and fields to the PainlessLookup.

@jdconrad jdconrad added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v7.0.0 >refactoring v6.5.0 labels Aug 7, 2018
@jdconrad jdconrad requested a review from rjernst August 7, 2018 20:08
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@jdconrad jdconrad mentioned this pull request Aug 7, 2018
23 tasks
Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I think we should return null instead of using exceptions to indicate a class is not found.

return handle;
try {
return painlessLookup.lookupRuntimeSetterMethodHandle(receiverClass, name);
} catch (IllegalArgumentException iae) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should use IAE as control flow. Can we return null if the the class is not found and base these special cases on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -174,4 +177,76 @@ public PainlessMethod lookupFunctionalInterfacePainlessMethod(Class<?> targetCla

return functionalInterfacePainlessMethod;
}

public PainlessMethod lookupRuntimePainlessMethod(Class<?> originalTargetClass, String methodName, int methodArity) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add at least a single line javadoc to these methods (and preferably the other ones as well here, although that could be in a followup)? It is getting difficult to understand what the differences in expected behavior are, eg based on a single word difference here of adding "runtime" to the method name, but taking the same args as lookupPainlessMethod above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to add documentation for all of these in a follow up PR as there are a few more changes lined up and I would prefer not to write it twice over the next couple weeks if that's okay.

@jdconrad
Copy link
Contributor Author

jdconrad commented Aug 8, 2018

@rjernst Thanks for the review. I changed all the methods in PainlessLookup to return null and react at the site of the calls instead of using exception handling as control flow. Ready for another round.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdconrad
Copy link
Contributor Author

jdconrad commented Aug 8, 2018

@rjernst Thanks for the reviews!

@jdconrad jdconrad merged commit 9b00f09 into elastic:master Aug 8, 2018
jdconrad added a commit that referenced this pull request Aug 8, 2018
This moves some run-time lookups for methods and fields to the PainlessLookup.
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >refactoring v6.5.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants